import { find } from 'lodash';

export const getTableColumns = ({ params, orgList, pointTypeList, alertTypeList, noticeTypeList }: any) => [
	{
		title: "接驳点ID",
		dataIndex: "id",
		width: 140,
		ellipsis: true
	},
	{
		title: "接驳点名称",
		dataIndex: "name",
		width: 140,
		ellipsis: true
	},
	{
		title: "接驳点类型",
		dataIndex: "type",
		width: 140,
		ellipsis: true,
		render: (_: any, record: any) => {
			const result = find(pointTypeList?.data || [], (item: any) => item.value === record.type)
			return (
				<span>
					{result?.label}
				</span>
			)
		}
	},
	{
		title: "所属组织",
		dataIndex: "createOrgId",
		width: 140,
		ellipsis: true,
		render: (_: any, record: any) => {
			const result = find(orgList?.data || [], (item: any) => item.id === record.createOrgId)
			return (
				<span>
					{result?.name}
				</span>
			)
		}
	},
	{
		title: "关联月台",
		dataIndex: "scName",
		width: 100,
		ellipsis: true,
	},
	{
		title: "等待时长(min)",
		dataIndex: "waitTime",
		width: 100,
		ellipsis: true,
		render: (_: any, record: any) => {
			return (
				<span>
					{record.waitTime / 60}
				</span>
			)
		}
	},
	{
		title: "通知状态",
		dataIndex: "notice",
		width: 100,
		ellipsis: true,
		render: (_: any, record: any) => {
			const result = find(noticeTypeList?.data || [], (item: any) => `${item.value}` === `${record.notice}`)
			return (
				<span>
					{result?.label}
				</span>
			)
		}
	},
	{
		title: "预警状态",
		dataIndex: "warning",
		width: 100,
		ellipsis: true,
		render: (_: any, record: any) => {
			const result = find(alertTypeList?.data || [], (item: any) => `${item.value}` === `${record.warning}`)
			return (
				<span>
					{result?.label}
				</span>
			)
		}
	},
	{
		title: "创建日期",
		dataIndex: "createTime",
		width: 140,
		ellipsis: true
	},
];


export const USER_STATUS = [
	{ label: '在线', value: 1 },
	{ label: '离线', value: 2 }
]

export const getSearchColumns = ({orgList, pointTypeList, sceneList}: any) => [
	{
		type: "input",
		placeholder: "接驳点名称",
		name: "name"
	},
	{
		type: "select",
		placeholder: "接驳点类型",
		name: "type",
		options: pointTypeList?.data || [],
	},
	{
		type: "select",
		placeholder: "所属组织",
		name: "createOrgId",
		options: orgList?.data || [],
		fieldProps:{
			fieldNames: {
				label: 'name',  // 显示文本对应的字段
				value: 'id',    // 值对应的字段
			}
		}
	},
	{
		type: "select",
		placeholder: "关联月台",
		name: "scId",
		options: sceneList?.data?.list || [],
		fieldProps:{
			fieldNames: {
				label: 'scName',  // 显示文本对应的字段
				value: 'id',    // 值对应的字段
			}
		}
	},
	{
		type: "input",
		placeholder: "等待时长",
		name: "waitTime"
	},
]